import React from 'react';
import {connect} from 'umi';
import {Button, PageHeader} from 'antd';
import MainTable from './mainTable';
import {PlusOutlined, ReloadOutlined} from "@ant-design/icons";
import style from "../userDemand/index.less";
import NewUserDemandModal from "../userDemand/newUserDemandModal";
import NewProductModal from "../offerSide/productList/newProductModal";


class MachineInfo extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            modalVisible: false,
            loading: false,
        }
    }

    // handle
    showModal = () => {
        this.props.dispatch({type: 'commonModel/getAllMachineInfo'});
        this.props.dispatch({type: 'commonModel/getCityList'});
        this.setState({modalVisible: true});
    };

    hideModal = () => {
        this.setState({modalVisible: false});
    };


    // life cycle
    initData = async () => {

    };

    componentWillMount() {
        this.initData().then(() => null)
    }

    render() {
        return (
            <div>
                <PageHeader title={'饮用水信息'} subTitle={'支持查看饮用水信息'}
                            extra={[
                                <Button loading={this.state.loading} onClick={this.initData} icon={<ReloadOutlined/>}
                                        type="primary">刷新</Button>,
                                // <Button onClick={this.showModal} icon={<PlusOutlined/>} type="primary">发布商品</Button>
                            ]}
                />
                <MainTable dataSource={this.props.machineInfo}
                           dispatch={this.props.dispatch}
                />

                {/*<NewProductModal visible={this.state.modalVisible} hide={this.hideModal}/>*/}
            </div>
        )
    }


}

function mapStateToProps({commonModel}) {
    const {machineInfo} = commonModel;
    return {machineInfo};
}

export default connect(mapStateToProps)(MachineInfo);
